package com.example.demo.huawei;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

/*
寻找身高相近的小朋友
输入：
100 10
95 96 97 98 99 101 102 103 104 105

输出：
99 101 98 102 97 103 96 104 95 105

 */
public class Main560 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int h1 = scanner.nextInt();
        int n = scanner.nextInt();
        List<Integer> res = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            res.add(scanner.nextInt());
        }
        Collections.sort(res);
        List<Integer> res2 = new ArrayList<>();
        for (int i = 0; i < 200; i++) {
            Iterator<Integer> iterator = res.iterator();
            while (iterator.hasNext()) {
                Integer next = iterator.next();
                if (Math.abs(next - h1) == i) {
                    res2.add(next);
                    iterator.remove();
                }
            }
        }
        res2.forEach(
                r -> System.out.print(r + " ")
        );
    }
}
